<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="password" id="">
    <input type="text" name="confirm_password" id="">
    <br>
    <span name="msg"></span>
    <script>
        // 逻辑运算符实际使用
        let a = 1;
        let b = 2;

        function query(name) {
            return document.querySelector(`[name='${name}']`);
        }
        console.log(query("password"));
        let inputs = document.querySelectorAll("[name='password'],[name='confirm_password']");
        console.log(inputs);
        [...inputs].map(item => {
            item.addEventListener('keyup', function () {
                let msg = "";
                if (query("password").value != query("confirm_password").value) {
                    msg = "输入密码不一致";
                }
                query("msg").innerHTML = msg;
            });
        });
    </script>
</body>

</html>